home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / MATRIX04.ARJ / MATSUBX.C < prev    next >
Text File  |  1992-05-24  |  1KB  |  48 lines

  1. /*
  2. *-----------------------------------------------------------------------------
  3. *    file:    matsubx.c
  4. *    desc:    find submatrix
  5. *    by:    ko shu pui, patrick
  6. *    date:    24 may 92 v0.4
  7. *    revi:
  8. *    ref:
  9. *       [1] Mary L.Boas, "Mathematical Methods in the Physical Sciene,"
  10. *    John Wiley & Sons, 2nd Ed., 1983. Chap 3.
  11. *
  12. *-----------------------------------------------------------------------------
  13. */
  14. #include <stdio.h>
  15. #include "matrix.h"
  16.  
  17. /*
  18. *-----------------------------------------------------------------------------
  19. *    funct:    mat_submat
  20. *    desct:    return a submatrix S of A
  21. *    given:    A = main matrix,
  22. *        i,j = row and column of A to be deleted to obtained S
  23. *    retrn:    S
  24. *-----------------------------------------------------------------------------
  25. */
  26. MATRIX mat_submat( A, i, j )
  27. MATRIX A;
  28. int i,j;
  29. {
  30.     int    m, m1, p, p1;
  31.     MATRIX    S;
  32.  
  33.     S = mat_creat(MatRow(A)-1, MatCol(A)-1, UNDEFINED);
  34.  
  35.     for (m=m1=0; m<MatRow(A); m++)
  36.         {
  37.         if (m==i) continue;
  38.         for (p=p1=0; p<MatCol(A); p++)
  39.             {
  40.             if (p==j) continue;
  41.             S[m1][p1] = A[m][p];
  42.             p1++;
  43.             }
  44.         m1++;
  45.         }
  46.  
  47.     return (S);
  48. }